<div class="pageContent">
	<div class="unitBox" style="margin-left:1px;"> 
		<form id="pagerForm" method="post" action="<?cs var:config.cgipath?>mt_slog_warn?action=search">
			<input type="hidden" name="pageNum" value="<?cs var:config.currentPage ?>" />
			<input type="hidden" name="numPerPage" value="<?cs var:config.numPerPage ?>" />
			<input type="hidden" name="orderField" value="<?cs var:config.orderField ?>" />
			<input type="hidden" name="orderDirection" value="<?cs var:config.orderDirection ?>" />

			<input type="hidden" name="dwc_warn_obj_type" value="<?cs var:config.dwc_warn_obj_type ?>" />
			<input type="hidden" name="dwc_warn_type" value="<?cs var:config.dwc_warn_type ?>" />
			<input type="hidden" name="dwc_warn_status" value="<?cs var:config.dwc_warn_status ?>" />
			<input type="hidden" name="dwc_obj_id" value="<?cs var:config.dwc_obj_id ?>" />
		</form>

		<div class="pageHeader" style="border:1px #B8D0D6 solid">
			<form onsubmit="return navTabSearch(this, 'dmt_slog_warn');" action="<?cs var:config.cgipath ?>mt_slog_warn?action=search" method="post">
			<div class="searchBar">
				<table class="searchContent" >
					<tr>
						<td>
							<label>告警对象：</label>
							<select name="dwc_warn_obj_type" id="dwc_warn_obj_type">
								<option value="0">全部</option>
								<option value="1">单机告警</option>
								<option value="2">视图告警</option>
							</select>
						</td>
						<td>
							<label>告警类型：</label>
							<select name="dwc_warn_type" id="dwc_warn_type">
								<option value="0">全部</option>
								<option value="1">最大值</option>
								<option value="2">最小值</option>
								<option value="4">波动值</option>
							</select>
						</td>
						<td>
							<label>告警状态：</label>
							<select name="dwc_warn_status" id="dwc_warn_status">
								<option value="0">全部</option>
								<option value="32">已屏蔽</option>
								<option value="64">未屏蔽</option>
							</select>
						</td>
						<td>
							告警对象 id：<input type="text" name="dwc_obj_id" size="10" value="<?cs var:config.dwc_obj_id ?>" />
						</td>
						<td>
							<button type="submit" class="sexybutton" id="dwc_btn_submit"><span><span><span class="search">查找</span></span></span></button>
							<button class="sexybutton" id="dwc_btn_erase" onclick="return dwcClearSearch()"><span><span><span class="erase">重填</span></span></span></button>
						</td>
					</tr>
				</table>
			</div>
			</form>
		</div>
		
		<div class="pageContent" style="border-left:1px #B8D0D6 solid;border-right:1px #B8D0D6 solid">
			<div class="panelBar">
				<ul class="toolBar">
					<li><a class="add" href="#" onclick="return dwcAddNewWarn(1);"><span>单机告警设置</span></a></li>
					<li class="line">line</li>
					<li><a class="add" href="#" onclick="return dwcAddNewWarn(2);"><span>视图告警设置</span></a></li>
					<li class="line">line</li>
					<li><a class="edit" href="#" onclick="return dwcModMultiWarn();"><span>批量修改告警</span></a></li>
					<li class="line">line</li>
					<li><a class="edit" href="#" onclick="return dwcMaskMultiWarn();"><span>批量屏蔽告警</span></a></li>
					<li class="line">line</li>
					<li><a class="edit" href="#" onclick="return dwcUmaskMultiWarn();"><span>批量解除屏蔽</span></a></li>
					<li class="line">line</li>
					<li><a class="delete" href="#" onclick="return dwcDelMultiWarn();"><span>批量删除告警</span></a></li>
					<li class="line">line</li>
				</ul>
			</div>

			<div id="dwc_warn_list">
				<table class="table" width="100%" layoutH="110">
					<thead>
						<tr>
							<th width="20">序号</th>
							<?cs if:config.order_attr_id ?>
							<th width="40" orderField="attr_id" class="<?cs var:config.order_attr_id ?>">监控点id</th>
							<?cs else ?>
							<th width="40" orderField="attr_id" class="asc">监控点id</th>
							<?cs /if ?>

							<th width="150">监控点名称</th>
							<th width="60">告警对象</th>

							<?cs if:config.order_warn_type_value ?>
							<th width="40" orderField="warn_type_value" class="<?cs var:config.order_warn__obj_type_value ?>">对象值</th>
							<?cs else ?>
							<th width="40" orderField="warn_type_value" class="asc">对象值</th>
							<?cs /if ?>

							<th width="110">告警类型</th>
							<th width="60">告警值</th>
							<th width="90">屏蔽状态</th>
							<?cs if:config.order_create_time ?>
							<th width="120" orderField="create_time" class="<?cs var:config.order_create_time ?>">添加时间</th>
							<?cs else ?>
							<th width="120" orderField="create_time" class="desc">添加时间</th>
							<?cs /if ?>
							<th width="22"><input type="checkbox" group="warn_ids" class="checkboxCtrl"></th>
						</tr>
					</thead>
					<tbody id="dwc_warn_list_info">
					</tbody>
				</table>
		
				<div class="panelBar" layoutH="0">
					<div class="pages">
						<span>每页显示</span>
						<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
							<option value="10">10</option>
							<option value="20">20</option>
							<option value="50">50</option>
							<option value="100">100</option>
							<option value="200">200</option>
						</select>
						<span>条，共 <?cs var:config.totalCount ?>  条</span>
					</div>
					<div class="pagination" targetType="navTab" totalCount="<?cs var:config.totalCount ?>" numPerPage="<?cs var:config.numPerPage ?>" pageNumShown="<?cs var:config.pageNumShown ?>" currentPage="<?cs var:config.currentPage ?>"></div>
				</div>
			</div> <!-- da_attr_list -->
		</div>
	</div> <!-- unitBox -->
</div>

<script language="javascript" type="text/javascript">
var dwc_warn_config = $.parseJSON('<?cs var:config.warn_config_info ?>');

function dwcSetWarnList(warninfo)
{
	var list = "";
	var listwarn = warninfo.list;
	var bhas = false;
	var warn_type = "<?cs var:config.dwc_warn_type ?>";
	for(var i=0,j=0; i < warninfo.count && i < listwarn.length; i++)
	{
		j = (<?cs var:config.currentPage ?>-1) * <?cs var:config.numPerPage ?> + 1;
		list += "<tr>";
		list += "<td>" + (i+j) + "</td>";
		list += "<td>" + listwarn[i].attr_id + "</td>";
		list += "<td>" + listwarn[i].attr_name + "</td>";
		if(listwarn[i].warn_flag & 8)
			list += "<td>单机</td>";
		else if(listwarn[i].warn_flag & 16)
			list += "<td>视图</td>";
		else
			list += "<td>未知</td>";
		list += "<td>" + listwarn[i].warn_obj_value + "</td>";

		list += "<td>";
		bhas = false;
		if(warn_type == "1" || (warn_type=="" && listwarn[i].warn_flag & 1)) {
			list += "最大值";
			bhas = true;
		}
		if(warn_type == "2" || (warn_type=="" && listwarn[i].warn_flag & 2)) {
			if(bhas) list += " | 最小值";
			else list += "最小值";
			bhas = true;
		}
		if(warn_type == "4" || (warn_type=="" && listwarn[i].warn_flag & 4)) {
			if(bhas) list += " | 波动值";
			else list += "波动值";
		}
		list += "</td>";

		list += "<td>";
		bhas = false;
		if(warn_type == "1" || (warn_type=="" && listwarn[i].warn_flag & 1)) {
			list += listwarn[i].warn_max;
			bhas = true;
		}
		if(warn_type == "2" || (warn_type=="" && listwarn[i].warn_flag & 2)) {
			if(bhas) { list += " | "; list += listwarn[i].warn_min; }
			else { list += listwarn[i].warn_min; }
			bhas = true;
		}
		if(warn_type == "4" || (warn_type=="" && listwarn[i].warn_flag & 4)) {
			if(bhas) { list += " | "; list += listwarn[i].warn_wave; }
			else list += listwarn[i].warn_wave;
		}
		list += "</td>";

		if(listwarn[i].warn_flag & 32)
			list += "<td style='color:#ff0000'>已屏蔽</td>";
		else
			list += "<td>未屏蔽</td>";
		list += "<td>" + listwarn[i].add_time + "</td>";
		list += "<td><input name='warn_ids' value=";
		list +=  listwarn[i].config_id + " type='checkbox'></td>";
		list += "</tr>";
	}
	return list;
}

function dwcClearSearch()
{
	$("#dwc_warn_type").val(0);
	$("#dwc_warn_obj_type").val(0);
	$("#dwc_warn_status").val(0);
	$("input[name=dwc_view_id]").val("");
	$("input[name=dwc_machine_id]").val("");
	$("input[name=dwc_obj_id]").val("");
	return false;
}

function dwcDelMultiWarn()
{
	var sel_config = "";
	$("#dwc_warn_list_info").find("input:checked").filter("[name='warn_ids']").each(function(i){
		var val = $(this).val();
		sel_config += (i==0 ? val : ","+val);
	});

	if(sel_config == "")
	{
		alertMsg.info("请选择要删除的告警");
		return;
	}

	alertMsg.confirm("确定要删除吗？", {
		okCall: function(){
			var url = "<?cs var:config.cgipath?>mt_slog_warn?action=del_multi_warn";
			url += "&warn_list=" + sel_config;
			ajaxTodo(url);
		}
	});
	return false;
}

function dwcUmaskMultiWarn()
{
	var sel_config = "";
	$("#dwc_warn_list_info").find("input:checked").filter("[name='warn_ids']").each(function(i){
		var val = $(this).val();
		sel_config += (i==0 ? val : ","+val);
	});

	if(sel_config == "")
	{
		alertMsg.info("请选择要解除屏蔽的告警");
		return;
	}

	var url = "<?cs var:config.cgipath?>mt_slog_warn?action=multi_umask_warn";
	url += "&ddwc_mod_warn_list=" + sel_config;
	url += "&c_warn_not_mask_sel=umask";
	ajaxTodo(url);
}

function dwcMaskMultiWarn()
{
	var sel_config = "";
	$("#dwc_warn_list_info").find("input:checked").filter("[name='warn_ids']").each(function(i){
		var val = $(this).val();
		sel_config += (i==0 ? val : ","+val);
	});

	if(sel_config == "")
	{
		alertMsg.info("请选择要屏蔽的告警");
		return;
	}

	var url = "<?cs var:config.cgipath?>mt_slog_warn?action=multi_mask_warn";
	url += "&ddwc_mod_warn_list=" + sel_config;
	url += "&c_warn_mask_sel=mask";
	ajaxTodo(url);
}

function dwcModMultiWarn()
{
	var sel_config = "";
	$("#dwc_warn_list_info").find("input:checked").filter("[name='warn_ids']").each(function(i){
		var val = $(this).val();
		sel_config += (i==0 ? val : ","+val);
	});

	if(sel_config == "")
	{
		alertMsg.info("请选择要修改的告警");
		return;
	}

	var url = "<?cs var:config.cgipath?>mt_slog_warn?action=mod_multi_warn";
	url += "&warn_list=" + sel_config;
	var op = $.parseJSON('{"mask":true,"maxable":false,"height":240,"width":560}'); 
	$.pdialog.open(url, "dwc_dlg_mod_multi_warn", "批量修改告警配置", op); 
}

function dwcAddNewWarn(type)
{
	var url = "<?cs var:config.cgipath?>mt_slog_warn?action=add_warn&type="+type;
	var op = $.parseJSON('{"mask":true,"maxable":false,"height":300,"width":560}'); 
	if(type == "1")
		$.pdialog.open(url, "dwc_dlg_add_new_mach_warn", "添加单机最值告警", op); 
	else
		$.pdialog.open(url, "dwc_dlg_add_new_view_warn", "添加视图最值告警", op); 
}

$(document).ready(function(){
	var warn_info = dwcSetWarnList(dwc_warn_config);
	var warn = $("#dwc_warn_list_info");
	warn.html(warn_info);

	$("select[name=dwc_warn_obj_type] option").each(function(){
		<?cs if:config.dwc_warn_obj_type ?>
			if(this.value == <?cs var:config.dwc_warn_obj_type ?>)
				$(this).attr("selected", true);
		<?cs /if ?>
	});

	$("select[name=dwc_warn_type] option").each(function(){
		<?cs if:config.dwc_warn_type ?>
			if(this.value == <?cs var:config.dwc_warn_type ?>)
				$(this).attr("selected", true);
		<?cs /if ?>
	});

	$("select[name=dwc_warn_status] option").each(function(){
		<?cs if:config.dwc_warn_status?>
			if(this.value == <?cs var:config.dwc_warn_status?>)
				$(this).attr("selected", true);
		<?cs /if ?>
	});


	$("select[name=numPerPage] option").each(function(){
		if(this.value == <?cs var:config.numPerPage ?>)
			$(this).attr("selected", true);
	});
});

</script>

